import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tiktokadult/config/config.dart';
import 'package:tiktokadult/hj_model/home/home_tabs_entity.dart';

import 'cartoon_sub_module_page.dart';

class CartoonSubModuleLogic extends GetxController with GetTickerProviderStateMixin {
  final int tabIndex; // 未初始化时,内链跳转需要
  final CommunityType type; //-1:动漫和漫画 0:图集 1:黄游 2:小说
  List<ModuleData> tabs = []; //漫画
  late TabController tabCtr;

  CartoonSubModuleLogic(this.tabIndex, {this.type = CommunityType.Pic});

  @override
  void onInit() {
    if (type == CommunityType.Pic) {
      //0-图集  showtype = 2,列表
      tabs.addAll(Config.plateModule?.picsUi ?? []);
    } else if (type == CommunityType.Game) {
      //1-黄游 showtype = 2,列表
      tabs.addAll(Config.plateModule?.gameUi ?? []);
    } else if (type == CommunityType.TextNovel) {
      //2-文字小说
      tabs.addAll(Config.plateModule?.novel ?? []);
    } else if (type == CommunityType.VoiceNovel) {
      //2-有声小说
      tabs.addAll(Config.plateModule?.audio ?? []);
    }
    tabCtr = TabController(
      initialIndex: tabIndex,
      length: tabs.length,
      vsync: this,
    );
    super.onInit();
  }

  void skipToTabIndex(int index) {
    tabCtr.index = index;
  }
}
